/**   
 * 文件名：TopicVO.java</br>
 * 描述： </br>
 * 开发人员：汪浩博 </br>
 * 创建时间： 2016-6-4
 */ 

package com.topic.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.base.util.BeanUtil;
import com.post.bean.Post;
import com.post.bean.PostVO;
import com.post.service.PostService;
import com.user.bean.BBSUser;

/** 
 * 类名: TopicVO</br> 
 * 包名：com.topic.bean </br> 
 * 描述: </br>
 * 发布版本号：</br>
 * 开发人员： 汪浩博</br>
 * 创建时间： 2016-6-4 
 */

public class TopicVO implements Serializable{
	
	private long id;
	private String topicName;		//主题名
	private String describe;		//描述
	private Long postNum;			//帖子数
	/** 
	 * 描述: </br>
	 * 开发人员：汪浩博</br>
	 * 创建时间：2016-6-4</br>
	 */
	public TopicVO() {
		// TODO Auto-generated constructor stub
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getTopicName() {
		return topicName;
	}
	public void setTopicName(String topicName) {
		this.topicName = topicName;
	}
	public String getDescribe() {
		return describe;
	}
	public void setDescribe(String describe) {
		this.describe = describe;
	}
	public Long getPostNum() {
		return postNum;
	}
	public void setPostNum(Long postNum) {
		this.postNum = postNum;
	}
	
	public List<TopicVO> beanTransVo(List<Topic> queryResult,PostService postService){
		ArrayList<TopicVO> list = new ArrayList<TopicVO>();
		for (Topic topic : queryResult) {
			long topicId = topic.getId();
			Long postNum = postService.getCountByTopic(topicId);
			TopicVO topicVO = new TopicVO();
			//属性拷贝
			BeanUtil.copyProperties(topicVO, topic);
			topicVO.setPostNum(postNum);
			list.add(topicVO);
		}
		return list;
	}
}
